package demo1;
class  Shape{
    public  void draw(){
        System.out.println("Shape::draw()");
    }
}
class  Rect extends Shape{
    public void draw(){
        System.out.println("♦");
    }
}
class Flower extends Shape{
    @Override
    public void draw() {
        System.out.println("❀");
    }
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("🔺");
    }
}
public class test {
    //多态
    public  static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main2(String[] args) {
        Rect rect=new Rect();
        drawMap(rect);
        Flower flower=new Flower();
        drawMap(flower);
        Triangle triangle=new Triangle();
        drawMap(triangle);
    }

    public static void main1(String[] args) {
        Shape shape1=new Rect();
        shape1.draw();
        Shape shape2=new Flower();
        shape2.draw();
    }

    public static void main(String[] args) {
        Rect rect=new Rect();
        Flower flower=new Flower();
        Triangle triangle=new Triangle();
        Shape[] shapes={triangle,rect,triangle,rect,flower};
        for (Shape shape:shapes){
            shape.draw();
        }
    }
}




























